Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 16dedc72c24acc83a667ff16071ca75142d52a86


Parents : 9d2da56
Author : Mark Qvist <mark@unsigned.io>
Date : 2025-04-13T02:23:01+02:00

BLE improvements

Changes

3 files changed, 11 insertions(+), 0 deletions(-)


Diff

diff --git a/BLESerial.cpp b/BLESerial.cpp
index 3460a86..80bcaf2 100644
--- a/BLESerial.cpp
+++ b/BLESerial.cpp
@@ -110,7 +110,10 @@ void BLESerial::begin(const char *name) {
BLEDevice::setSecurityCallbacks(this);
SetupSerialService();
+ this->startAdvertising();
+}
+void BLESerial::startAdvertising() {
ble_adv = BLEDevice::getAdvertising();
ble_adv->addServiceUUID(BLE_SERIAL_SERVICE_UUID);
ble_adv->setMinPreferred(0x20);
@@ -119,6 +122,11 @@ void BLESerial::begin(const char *name) {
ble_adv->start();
}
+void BLESerial::stopAdvertising() {
+ ble_adv = BLEDevice::getAdvertising();
+ ble_adv->stop();
+}
+
void BLESerial::end() { BLEDevice::deinit(); }
void BLESerial::onWrite(BLECharacteristic *characteristic) {

diff --git a/BLESerial.h b/BLESerial.h
index 7b6d1c6..1dcae99 100644
--- a/BLESerial.h
+++ b/BLESerial.h
@@ -78,6 +78,8 @@ public:
void begin(const char *name);
void end();
+ void startAdvertising();
+ void stopAdvertising();
void onWrite(BLECharacteristic *characteristic);
int available();
int peek();

diff --git a/Bluetooth.h b/Bluetooth.h
index a93a2df..3d29178 100644
--- a/Bluetooth.h
+++ b/Bluetooth.h
@@ -266,6 +266,7 @@ char bt_devname[11];
// Serial.println("Authentication fail");
ble_authenticated = false;
bt_state = BT_STATE_ON;
+ bt_update_passkey();
bt_security_setup();
}
bt_allow_pairing = false;


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────